package is.api.demo.rest.utils;


import org.springframework.util.StringUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;

/**********************************************************************
 * &lt;p&gt;文件名：DateUtils.java &lt;/p&gt;
 * &lt;p&gt;文件描述：${DESCRIPTION}(接口调用类型)
 * @project_name：funi-platform-talentsplace
 * @author shunyao.zeng
 * @date 2018/1/12 10:38
 * @history
 * @department：政务事业部
 * Copyright ChengDu Funi Cloud Code Technology Development CO.,LTD 2014
 *                    All Rights Reserved.
 */
public abstract class DateUtils {
    /**
     * 日期格式化为文本
     *
     * @param date
     * @param pattern
     * @return
     */
    public static String format(final Date date, final String pattern) {
        if (Objects.isNull(date)) {
            return null;
        }
        if (StringUtils.isEmpty(pattern)) {
            return null;
        }
        return (new SimpleDateFormat(pattern)).format(date);
    }
}
